package top.songxs.gmall.product.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.songxs.gmall.common.result.Result;
import top.songxs.gmall.common.result.ResultCodeEnum;
import top.songxs.gmall.product.entity.SpuImage;
import top.songxs.gmall.product.service.SpuImageService;

import java.util.List;

@RestController
@RequestMapping("/admin/product")
public class SpuImageController {
    @Autowired
    private SpuImageService spuImageService;

        //http://api.gmall.com/admin/product/spuImageList/{spuId}
        //spuId：spuId
        //Get
    @GetMapping("spuImageList/{spuId}")
    public Result<List<SpuImage>> findSpuImageBySpuId(@PathVariable("spuId") Integer spuId) {
        List<SpuImage> list = spuImageService.findSpuImageBySpuId(spuId);
        return Result.build(list, ResultCodeEnum.SUCCESS);

    }
}
